//#include <iostream>
//#include <queue>
//using namespace std;
//
//const int N = 1e5 + 10;
//
//int a[N], b[N];
//
//class node{
//	public:
//		int sum;
//		int i, j;
//		
//		bool operator<(const node& x) const
//		{
//			return sum > x.sum;
//		}																															                                                                                                                              
//};
//
//int main()
//{
//	priority_queue<node> heap;
//	
//	int n; cin >> n;
//	for (int i = 1; i <= n; i++) cin >> a[i];
//	for (int i = 1; i <= n; i++) cin >> b[i];
//	
//	for(int i = 1; i <= n; i++)
//	{
//		heap.push({a[i] + b[1], i, 1});
//	}
//	
//	while (n--)
//	{
//		node t = heap.top(); heap.pop();
//		int sum = t.sum, i = t.i, j = t.j;
//		
//		cout << sum << " ";
//		heap.push({a[i] + b[j + 1], i, j + 1});
//	}
//	
//	return 0;
// } 



#include <iostream>
#include <queue>
#include <vector>
using namespace std;

const int N = 2e5 + 10;

int gen[N], e[N], ne[N], pre[N];
bool qu[N];

class node{
	public:
		int ab;
		int l, r;
		
		bool operator<(const node& x) const
		{
			if (ab != x.ab) return ab > x.ab;
			else if (l != x.l) return l > x.l;
			else return r < x.r;
		}
};

int main()
{
	int n; cin >> n;
	for (int i = 1; i <= n; i++)
	{
		char ch; cin >> ch;
		if (ch == 'B') gen[i] = 1;
	}
	
	for (int i = 1; i <= n; i++)
	{
		cin >> e[i];
		ne[i] = i + 1;
		pre[i] = i - 1;
	} 
	ne[n] = 0;
	
	priority_queue<node> heap;
	
	for (int i = 2; i <= n; i++)
	{
		if (gen[i] != gen[i - 1]) heap.push({abs(e[i] - e[i - 1]), i - 1, i});
	}
	
	vector<node> queue;
	
	while (heap.size())
	{
		node t = heap.top(); heap.pop();
		int ab = t.ab, l = t.l, r = t.r;
		
		if (qu[l] || qu[r]) continue;
		
		queue.push_back(t);
		ne[pre[l]] = ne[r];
		pre[ne[r]] = pre[l];
		qu[l] = qu[r] = true;
		
		int left = pre[l], right = ne[r];
		if (left && right && gen[left] != gen[right])
		{
			heap.push({abs(e[left] - e[right]), left, right});
		}
	}
	
	cout << queue.size() << endl;
	for (auto& x : queue)
	{
		cout << x.l << " " << x.r << endl;
	}
	
	return 0;
 } 
